package com.sample.dubbo.client.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.sample.dubbo.api.server.IDemoService;
import com.sample.dubbo.api.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zwg
 * @date 2018-11-11 20:27
 **/

@RestController
@RequestMapping("demo")
public class DemoController {


    //@Autowired
    /**
     * 如果接口注册的时候提供了版本号，使用时也要指定版本号
     */
    @Reference(interfaceClass = IDemoService.class,version = "1.0")
    IDemoService demoService;


    @GetMapping("/user")
    public UserVo getUser(@RequestParam(value = "name", required = false) String name){

        return demoService.getUser(name);
    }


}
